package org.consumer;

import java.io.IOException;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.dubbo.remoting.RemotingException;

import net.sidland.service.BackService;
import net.sidland.service.HelloService;

/**
 * Hello world!
 *
 */
public class ConsumerApp {

	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException, InterruptedException, RemotingException {
		System.out.println("-----------------start-------------------");
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "applicationContext.xml" });  
        context.start();  

        BackService backService = (BackService) context.getBean("backService");
        HelloService demoService = (HelloService) context.getBean("helloService");
        for (int i=0;i<Integer.MAX_VALUE;i++) {
            String hello = demoService.sayHello("tom"+i);
            String back = backService.backHello("tom"+i);
            System.out.println("say :"+hello);
            System.out.println("back:"+back);
            Thread.sleep(2000);
        }
        System.in.read();  
		System.out.println("-----------------end-------------------");
	}
}
